﻿Public Class VariabelePrijsForm

#Region "Properties"

    Private _prijs As Decimal = 0
    ''' <summary>
    ''' Gebruikt om achteraf op het ticket af te printen
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    Public Property Prijs() As Decimal
        Get
            Return _prijs
        End Get
        Set(ByVal value As Decimal)
            _prijs = value
        End Set
    End Property

    Public ReadOnly Property ExtraOmschrijving() As String
        Get
            Return tbOmschrijving.Text
        End Get
    End Property

#End Region

#Region "Constructor"

    Public Sub New()
        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        tbPrijs.BackColor = Constants.Kleuren.ONGELDIG
    End Sub

#End Region

#Region "Events"

    Private Sub tbPrijs_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbPrijs.TextChanged
        Prijs = Utility.ToDecimal(tbPrijs.Text)
        If (Prijs > 0D) Then
            tbPrijs.BackColor = Constants.Kleuren.KLAAR_VOOR_SCAN
            btnOK.Enabled = True
        Else
            tbPrijs.BackColor = Constants.Kleuren.ONGELDIG
            btnOK.Enabled = False
        End If
    End Sub

    ' niet meer nodig, wordt op OK-knop afgecheckt
    'Protected Overrides Sub OnFormClosing(ByVal e As FormClosingEventArgs)
    '    MyBase.OnFormClosing(e)
    '    ' niet laten sluiten zolang er geen geldig bedrag ingetikt is
    '    If (Me.DialogResult = Windows.Forms.DialogResult.OK AndAlso Not btnOK.Enabled) Then e.Cancel = True
    'End Sub

    Protected Overrides Sub OnKeyUp(ByVal e As KeyEventArgs)
        MyBase.OnKeyUp(e)
        Select Case e.KeyCode
            Case Keys.F2
                btnOK_Click(Me, EventArgs.Empty)
        End Select
    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        If (Not btnOK.Enabled) Then Return
        Me.DialogResult = Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

#End Region

End Class